#include "DigitalOut.h"
#include "FrmDisplay.h"
#include "events.h"
#include "Timer.h"
#include "Control.h"
#include "GetAnalog.h"
#include "FrmParamModify.h"
#include "ModbusRegister.h"
#include "Alarm.h"
#include "IDriver.h"
#include "Register.h"
u16 ModifyCur;
u8 DEC2;
static u8 CurFlash;
static u8 ControllerSet1, ControllerSet2,ControlFlag;


u16 Get_ModifyCur()
{
  return ModifyCur;
}

static void Return(u8 ft)
{
  FormStatus = STATUS_QUIT;
  FormTo = ft;
}

static void Set_ModefyCur(void)
{
  switch (LastForm)
  {
  case DEF_CONTROLFORM:

    ModifyCur = ModifyCur - CONTROL_START;
    break;
  case DEF_DEFROSTFORM:

    ModifyCur = ModifyCur - DEFROST_START;
    break;
  case DEF_ALARMFORM:

    ModifyCur = ModifyCur - ALARM_START;
    break;
  case DEF_FANFORM:

    ModifyCur = ModifyCur - FAN_START;
    break;
  case DEF_LIGHTFORM:
 
    ModifyCur = ModifyCur - LIGHT_START;
    break;
  case DEF_SYSTEMFORM:

    ModifyCur = ModifyCur - SYSTEM_START;
    break;
  case DEF_DTCLOCKFORM:
    ModifyCur = ModifyCur - HREG_DEFROST_TIMER1;
    break;
  case DEF_LTCLOCKFORM:

    ModifyCur = ModifyCur - LT_START;
    break;

  }
}

static void Controller_TpyeDisplay(void)
{
  if (HREG_CONTROLLER_TYPE_SET == ModifyCur)
  {
		if(ControlFlag == 0 )
		{
      DisplayMainChars(GetParamDisplayName(GC_FormString[ControllerSet1]));
		}
		else
		{
      switch (ControllerSet1)
     {
      case 0:
        DisplayMainChars(GetParamDisplayName(GC1_FormString[ControllerSet2]));
      break;
      case 1:
        DisplayMainChars(GetParamDisplayName(GC2_FormString[ControllerSet2]));
      break;
      case 2:
        DisplayMainChars(GetParamDisplayName(GC3_FormString[ControllerSet2]));
      break;
      case 3:
        DisplayMainChars(GetParamDisplayName(GC4_FormString[ControllerSet2]));
      break;
      case 4:
        DisplayMainChars(GetParamDisplayName(GC5_FormString[ControllerSet2]));
      break;
      case 5:
        DisplayMainChars(GetParamDisplayName(GC6_FormString[ControllerSet2]));
      break;
      case 6:
        DisplayMainChars(GetParamDisplayName(GC7_FormString[ControllerSet2]));
      break;
      case 7:
        DisplayMainChars(GetParamDisplayName(GC8_FormString[ControllerSet2]));
      break;
      case 8:
        DisplayMainChars(GetParamDisplayName(GC9_FormString[ControllerSet2]));
      break;
      case 9:
        DisplayMainChars(GetParamDisplayName(GC10_FormString[ControllerSet2]));
      break;
      case 10:
        DisplayMainChars(GetParamDisplayName(GC11_FormString[ControllerSet2]));
      break;
      case 11:
        DisplayMainChars(GetParamDisplayName(GC12_FormString[ControllerSet2]));
      break;
      case 12:
        DisplayMainChars(GetParamDisplayName(GC13_FormString[ControllerSet2]));
      break;
      case 13:
        DisplayMainChars(GetParamDisplayName(GC14_FormString[ControllerSet2]));
      break;
      case 14:
        DisplayMainChars(GetParamDisplayName(GC15_FormString[ControllerSet2]));
      break;
      case 15:
        DisplayMainChars(GetParamDisplayName(GC16_FormString[ControllerSet2]));
			break;
			case 16:
				
        DisplayMainChars(GetParamDisplayName(GC17_FormString[ControllerSet2]));
			break;
			case 17:
				
        DisplayMainChars(GetParamDisplayName(GC18_FormString[ControllerSet2]));
			break;
			case 18:
        DisplayMainChars(GetParamDisplayName(GC19_FormString[ControllerSet2]));
      break;
     }		}
  }
}
/*
 * ��ʾ����������ͼ��
 */
static void DispParam(void)
{
  u16 StartHour, StartMinute;
  u16 CurrentTime;
  s16 Value;

//  StartTime = GetJDParamValue(Get_SetupCur());
	StartHour = (ValueToEdit>>8)/16*10 +(ValueToEdit>>8)%16;
	StartMinute =(ValueToEdit&0x00FF)/16*10 +(ValueToEdit&0x00FF)%16 ;
  CurrentTime = 100 * StartHour + StartMinute;

  if (HREG_CONTROLLER_TYPE_SET == ModifyCur)
	{
    Controller_TpyeDisplay();
    return;
	}
	
  if(((ModifyCur == HREG_TWO_DEFROST_MAX_TIME_INTERVAL)||(ModifyCur == HREG_DEFROST_HEATER_DELAY)||(ModifyCur == HREG_SHORT_CYCLE_PROTECTION_DELAY))&&(DEF_EXTRA_INFO_FORM != LastForm))
	{
		CurrentTime = (ValueToEdit/6)*100;
		CurrentTime += (ValueToEdit%6)*10;
		DisplayMainValues(CurrentTime, 1, 0); 
	}
  else if ( (DEF_NTCLOCKFORM == LastForm)
		|| ((DEF_DEFROSTFORM == LastForm)&&(ModifyCur>=HREG_DEFROST_TIMER1)&&(ModifyCur<=HREG_DEFROST_TIMER12))
				 || ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_LIGHTING_START_TIMER1)&&(ModifyCur<=HREG_LIGHTING_STOP_TIMER4))
							|| ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_DAY_START1)&&(ModifyCur<=HREG_DAY_STOP4)))
  {
	 if(ValueToEdit == 0x2400)
	 {
		 	 DisplayChars("----");
	 }
	 else
	 {
    DisplayMainValues(CurrentTime, 1, 0); 
	 }
  }
	else if((DEF_EXTRA_INFO_FORM == LastForm && 1 == KeyInforDownCount)
		|| (LastForm == DEF_SYSTEMFORM && HREG_HOUR_MINUTE == ModifyCur))
	{
		 DisplayMainValues(CurrentTime, 1, 0); 
	}
  else
  {
    DEC2 = GetParamDec(Get_SetupCur());

    Value = ValueToEdit;
		if ((DEF_EXTRA_INFO_FORM == LastForm)&&(LOCK_POSITION == KeyInforDownCount))
		 {
			    Value = ValueToEdit ;
		 }
		if(((ModifyCur >= HREG_DEF_CALI)&&(ModifyCur <= HREG_CONTROL_CALI))&&(Value==11))
		{
			
			 DisplayChars("----");
		}
		else if(((ModifyCur == HREG_HIGH_TEMP_ALARM_DELAY)||(ModifyCur <= HREG_LOW_TEMP_ALARM_DELAY))&&(Value==251))
		{
			 DisplayChars("----");
		}
		else
		{
			if (ONE_DOT == DEC2)
			{
				DisplayMainValues(Value, 0, 0); //DisPlayOneDotTemp(Value);
			}
			else
			{
				DisplayMainValues(Value, 0, DEC2);
			}
		}
  }
}

static void AddValue(int v)
{
	u16 TimeValue;
  ValueToEdit += v;
	if ((DEF_EXTRA_INFO_FORM == LastForm) && (LOCK_POSITION == KeyInforDownCount))
  {
       if (ValueToEdit < 0)
      {
       ValueToEdit = 0;
      }
      if (ValueToEdit >1)
      {
        ValueToEdit = 1;
       }
			 DisplayMainValues(ValueToEdit, 0, 0); //DisPlayOneDotTemp(ValueToEdit);
	}
	else
	{
//    	if ((HREG_DEFOST_MANUAL == ModifyCur) && (ValueToEdit > 2))
//			{
//						ValueToEdit = 2;
//			}
			if (ValueToEdit > Param_Get_MAX(ModifyCur))
			{
				
				ValueToEdit = Param_Get_MAX(ModifyCur);

			}
			if (ValueToEdit < Param_Get_MIN(ModifyCur))
			{
				ValueToEdit = Param_Get_MIN(ModifyCur);
			}
   
			if (HREG_CONTROLLER_TYPE_SET == ModifyCur) 
			{
				if(ControlFlag)
				{
					ControllerSet2++;
						if(ControllerSet2>GetControllerType2Max(ControllerSet1))
						{
							ControllerSet2 = 0;
						}
				}
				else
				{
					ControllerSet2 = 0;
					ControllerSet1++;
					if(ControllerSet1>18)
					{
						ControllerSet1 = 0;
					}
				}
				Controller_TpyeDisplay();
				return;
			}

			DEC2 = GetParamDec(ModifyCur);
			
			if((ModifyCur == HREG_TWO_DEFROST_MAX_TIME_INTERVAL)||(ModifyCur == HREG_DEFROST_HEATER_DELAY)||(ModifyCur == HREG_SHORT_CYCLE_PROTECTION_DELAY))
			{
				TimeValue = (ValueToEdit/6)*100;
				TimeValue += (ValueToEdit%6)*10;
				DisplayMainValues(TimeValue, 1, 0); 
			}
			else	if(((ModifyCur >= HREG_DEF_CALI)&&(ModifyCur <= HREG_CONTROL_CALI))&&(ValueToEdit==11))
			{
				
				 DisplayChars("----");
			}
			else if(((ModifyCur == HREG_HIGH_TEMP_ALARM_DELAY)||(ModifyCur <= HREG_LOW_TEMP_ALARM_DELAY))&&(ValueToEdit==251))
			{
				 DisplayChars("----");
			}
			else
			{
				if (ONE_DOT == DEC2)
				{
					DisplayMainValues(ValueToEdit, 0, 0); //DisPlayOneDotTemp(ValueToEdit);
				}
				else
				{
					DisplayMainValues(ValueToEdit, 0, DEC2);
				}
			}
  }
}

static void DecValue(int v)
{
	u16 TimeValue;
  ValueToEdit -= v;
	if ((DEF_EXTRA_INFO_FORM == LastForm) && (LOCK_POSITION == KeyInforDownCount))
    {
       if (ValueToEdit < 0)
      {
       ValueToEdit = 0;
      }
      if (ValueToEdit >1)
      {
        ValueToEdit = 1;
       }
			 DisplayMainValues(ValueToEdit, 0, 0); //DisPlayOneDotTemp(ValueToEdit);
    }
		else
		{
  if (ValueToEdit < Param_Get_MIN(ModifyCur))
  {
    ValueToEdit = Param_Get_MIN(ModifyCur);
  }
  if (ValueToEdit > Param_Get_MAX(ModifyCur))
  {
    ValueToEdit = Param_Get_MAX(ModifyCur);
  }
  DEC2 = GetParamDec(ModifyCur);

  if (HREG_CONTROLLER_TYPE_SET == ModifyCur) 
  {
		if(ControlFlag)
		{
			ControllerSet2--;
			if((ControllerSet2>= 4)&&(ControllerSet1<= 0xFF))
			{
				ControllerSet2 = GetControllerType2Max(ControllerSet1);
			}
		}
		else
		{
			ControllerSet2 = 0;
			ControllerSet1--;
			if((ControllerSet1>= 19)&&(ControllerSet1<= 0xFF))
			{
				ControllerSet1 = 18;
			}
		}
    Controller_TpyeDisplay();
    return;
  }
		
  if((ModifyCur == HREG_TWO_DEFROST_MAX_TIME_INTERVAL)||(ModifyCur == HREG_DEFROST_HEATER_DELAY)||(ModifyCur == HREG_SHORT_CYCLE_PROTECTION_DELAY))
	{
		TimeValue = (ValueToEdit/6)*100;
		TimeValue += (ValueToEdit%6)*10;
		DisplayMainValues(TimeValue, 1, 0);
	}
	else if(((ModifyCur >= HREG_DEF_CALI)&&(ModifyCur <= HREG_CONTROL_CALI))&&(ValueToEdit==11))
	{
		
		 DisplayChars("----");
	}
	else if(((ModifyCur == HREG_HIGH_TEMP_ALARM_DELAY)||(ModifyCur <= HREG_LOW_TEMP_ALARM_DELAY))&&(ValueToEdit==251))
	{
		 DisplayChars("----");
	}
	else
	{
		if (ONE_DOT == DEC2)
		{
			DisplayMainValues(ValueToEdit, 0, 0); //DisPlayOneDotTemp(ValueToEdit);
		}
		else
		{
			DisplayMainValues(ValueToEdit, 0, DEC2);
		}
   }
  }
}

static void
TimerAddValue(int v)
{
  u16 CurrentTime;
	u8 CurrentHour,CurrentMinite;

	CurrentHour = (ValueToEdit>>8)/16*10 +(ValueToEdit>>8)%16;
	CurrentMinite =(ValueToEdit&0x00FF)/16*10 +(ValueToEdit&0x00FF)%16 ;
	CurrentTime= CurrentHour*60+CurrentMinite;
	CurrentTime += v;
	
  if (DEF_EXTRA_INFO_FORM == LastForm) 
  {
    if (CurrentTime >= 24*60)
    {
      ValueToEdit = 0;
			CurrentHour = 0;
	    CurrentMinite =0;
			CurrentTime = 0;
    }
		CurrentHour = CurrentTime/60;
		CurrentMinite = CurrentTime%60 ;
		
    if (CurrentMinite>= 60)
    {
			CurrentHour = CurrentHour+1;
			CurrentMinite =CurrentMinite-60;

    }

		ValueToEdit = ((CurrentHour/10*16+ CurrentHour%10)<<8 )+(CurrentMinite/10*16+CurrentMinite%10);
		CurrentTime = CurrentHour*100+ CurrentMinite;

		DisplayMainValues(CurrentTime, 1, 0);
	}
  else
  {
    if (CurrentTime > 24*60)
    {
      ValueToEdit = 0;
			CurrentHour = 0;
	    CurrentMinite =0;
			CurrentTime = 0;
    }
			CurrentHour = CurrentTime/60;
	    CurrentMinite = CurrentTime%60 ;
  if (CurrentMinite>= 60)
	{
		CurrentHour = CurrentHour+1;
		CurrentMinite =CurrentMinite-60;

	}

		ValueToEdit = ((CurrentHour/10*16+ CurrentHour%10)<<8 )+(CurrentMinite/10*16+CurrentMinite%10);
		CurrentTime = CurrentHour*100+ CurrentMinite;

		if(ValueToEdit == 0x2400)
	 {
		 	 DisplayChars("----");
	 }
	 else
	 {
     DisplayMainValues(CurrentTime, 1, 0);
	 }
  }
}

static void
TimerDecValue(int v)
{
   s16 CurrentTime;
	 u8 CurrentHour,CurrentMinite;

   CurrentHour = (ValueToEdit>>8)/16*10 +(ValueToEdit>>8)%16;
	 CurrentMinite =(ValueToEdit&0x00FF)/16*10 +(ValueToEdit&0x00FF)%16 ;

	 CurrentTime= CurrentHour*60+CurrentMinite;
	 CurrentTime -= v;
  if (DEF_EXTRA_INFO_FORM == LastForm) 
  {
//    if (ValueToEdit < 0)
//    {
//      ValueToEdit = 0x2359;
//			CurrentHour = 23 ;
//			CurrentMinite = 59;
//    }
//     if (CurrentMinite >= 60)
//    {
//			CurrentHour = CurrentHour;
//			CurrentMinite =59;
//			ValueToEdit = ((CurrentHour/10*16+ CurrentHour%10)<<8 )+(CurrentMinite/10*16+CurrentMinite%10);
//    }
//		  if (CurrentHour >= 24)
//    {
//			CurrentHour = CurrentHour;
//			CurrentMinite =59;
//			ValueToEdit = ((CurrentHour/10*16+ CurrentHour%10)<<8 )+(CurrentMinite/10*16+CurrentMinite%10);
//    }
//       CurrentTime = CurrentHour*100+ CurrentMinite;
//     DisplayMainValues(CurrentTime, 1, 0);
		
   if (CurrentTime < 0)
   {
      CurrentTime = 23*60+59;
   }	
	  CurrentHour = CurrentTime/60;
	  CurrentMinite =CurrentTime%60 ;
	  ValueToEdit = ((CurrentHour/10*16+ CurrentHour%10)<<8 )+(CurrentMinite/10*16+CurrentMinite%10);
	  CurrentTime = CurrentHour*100+ CurrentMinite;
    DisplayMainValues(CurrentTime, 1, 0);
			
  }
  else
  {
   if (CurrentTime < 0)
   {
      CurrentTime = 24*60;
   }	
	  CurrentHour = CurrentTime/60;
	  CurrentMinite =CurrentTime%60 ;
	  ValueToEdit = ((CurrentHour/10*16+ CurrentHour%10)<<8 )+(CurrentMinite/10*16+CurrentMinite%10);
	  CurrentTime = CurrentHour*100+ CurrentMinite;
	 if(ValueToEdit == 0x2400)
	 {
		 	DisplayChars("----");
	 }
	 else
	 {
			DisplayMainValues(CurrentTime, 1, 0);
	 }
	}
}

static void
ParamModifyFormProcReleaseKey(u8 chr)
{

  switch (chr)
  {
  case Key_Up:
   if (((DEF_EXTRA_INFO_FORM == LastForm) && (1 == KeyInforDownCount))
		        || ((DEF_DEFROSTFORM == LastForm)&&(ModifyCur>=HREG_DEFROST_TIMER1)&&(ModifyCur<=HREG_DEFROST_TIMER12))
              	 || ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_LIGHTING_START_TIMER1)&&(ModifyCur<=HREG_LIGHTING_STOP_TIMER4))
                    || ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_DAY_START1)&&(ModifyCur<=HREG_DAY_STOP4))
												|| ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur == HREG_HOUR_MINUTE)))
    {
      TimerAddValue(1);
    }
   
    else
    {
      AddValue(1);
    }

    break;
  case Key_Down:

   if (((DEF_EXTRA_INFO_FORM == LastForm) && (1 == KeyInforDownCount))
		        || ((DEF_DEFROSTFORM == LastForm)&&(ModifyCur>=HREG_DEFROST_TIMER1)&&(ModifyCur<=HREG_DEFROST_TIMER12))
              	 || ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_LIGHTING_START_TIMER1)&&(ModifyCur<=HREG_LIGHTING_STOP_TIMER4))
                    || ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_DAY_START1)&&(ModifyCur<=HREG_DAY_STOP4))
												|| ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur == HREG_HOUR_MINUTE)))
   {
      TimerDecValue(1);
    }
    else
    {
      DecValue(1);
    }

    break;
  case Key_DSwitch:
    Return(DEF_MAINFORM);
    break;
  case Key_Set:
		if(( DEF_SYSTEMFORM== LastForm) && (HREG_CONTROLLER_TYPE_SET == ModifyCur))
		{
      if(ControlFlag)
			{
				ValueToEdit = ControllerSet1+((ControllerSet2)<<8);
				SetParamRegisterValue(ModifyCur, ValueToEdit);
				ControlFlag = 0;
			}
			else
			{
				ControlFlag = 1;		
				Controller_TpyeDisplay();
         break;				
			}
		}
     else if ((DEF_EXTRA_INFO_FORM == LastForm) && (1 == KeyInforDownCount))
    {
       SetParamRegisterValue(ModifyCur, ValueToEdit);
    }
		else if ((DEF_EXTRA_INFO_FORM == LastForm) && (LOCK_POSITION == KeyInforDownCount))
    {
         Controller.LockMode = ValueToEdit ;
    }
		else 
		{
			 if (GetJDParamValue(ModifyCur) != ValueToEdit) 
       {
        SetParamRegisterValue(ModifyCur, ValueToEdit);
       }
		}
//    AddValue(1);
    if (LastForm != DEF_EXTRA_INFO_FORM)
    {
      Set_SetupFormPrevForm(DEF_MODIFYFORM);
    }
    Set_ModefyCur();
		 if ((DEF_EXTRA_INFO_FORM == LastForm) && (LOCK_POSITION == KeyInforDownCount))
    {
			  
         Return(DEF_MAINFORM);
    }
		else
		{
    Return(LastForm);
		}
    break;
  case Key_CSwitch:
		
    Return(DEF_MAINFORM);
    break;
  default:
    break;
  }
  auto_return = 0;
}

static void
ParamModifyFormProcRepeatKey(u8 chr)
{
  switch (chr)
  {
  case Key_Up:
  if (((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_LIGHTING_START_TIMER1)&&(ModifyCur<=HREG_LIGHTING_STOP_TIMER4))
		      || ((DEF_DEFROSTFORM == LastForm)&&(ModifyCur>=HREG_DEFROST_TIMER1)&&(ModifyCur<=HREG_DEFROST_TIMER12)) 
		       || ((DEF_EXTRA_INFO_FORM == LastForm) && (1 == KeyInforDownCount))
              || ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_DAY_START1)&&(ModifyCur<=HREG_DAY_STOP4))
									|| ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur == HREG_HOUR_MINUTE)))
    {
      TimerAddValue(10);
    }
    else
    {
      AddValue(2);
    }
    break;
  case Key_Down:
  if (((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_LIGHTING_START_TIMER1)&&(ModifyCur<=HREG_LIGHTING_STOP_TIMER4))
		     || ((DEF_DEFROSTFORM == LastForm)&&(ModifyCur>=HREG_DEFROST_TIMER1)&&(ModifyCur<=HREG_DEFROST_TIMER12)) 
	           || ((DEF_EXTRA_INFO_FORM == LastForm) && (1 == KeyInforDownCount))
									|| ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur>=HREG_DAY_START1)&&(ModifyCur<=HREG_DAY_STOP4))
											|| ((DEF_SYSTEMFORM == LastForm)&&(ModifyCur == HREG_HOUR_MINUTE)))
    {
      TimerDecValue(10);
    }
    else
    {
      DecValue(2);
    }
    break;
  }
	 auto_return = 0;
}


	
static void
OneSecTick(void)
{
  u16 TicksNow,TicksElapsed;
  u16 Timeout;
  TicksNow = Timer2_Get16Ticks();
  TicksElapsed = TicksNow - SecUpdate;
	  if (CurFlash)
      Timeout = 900;
    else
      Timeout = 300;

  if (TicksElapsed < Timeout)
    return; 
     SecUpdate = TicksNow;
    if (CurFlash)
    {
      CurFlash = 0;
      DisplayMainChars("   ");
    }
    else
    {
      CurFlash = 1;
			DispParam();
			
    }
	
}





void ParamModify_Form(void)
{
  TEvent *e;
//  u16 CurrentTime;
  if (FormStatus == STATUS_INIT)
  {
    FormStatus = STATUS_RUN;
    ModifyCur = Get_SetupCur();
    if ((DEF_EXTRA_INFO_FORM == LastForm))
    {
      if (1 == KeyInforDownCount)
      {
        ModifyCur = HREG_HOUR_MINUTE;
      }
    }
		 if ((DEF_EXTRA_INFO_FORM == LastForm)&&(LOCK_POSITION == KeyInforDownCount))
		 {
					ValueToEdit = Controller.LockMode ;
		 }
		 else
		 {
					ValueToEdit = GetJDParamValue(ModifyCur);
		 }
    if ((DEF_EXTRA_INFO_FORM == LastForm) && (1 == KeyInforDownCount))
    {
  //    CurrentTime = IGet_ReadTime(2) << 8 | IGet_ReadTime(1);
      ValueToEdit = (( IGet_ReadTime(2))/10*16+( IGet_ReadTime(2))%10)<<8 |(( IGet_ReadTime(1))/10*16+( IGet_ReadTime(1))%10);
    }
    //CurFlash = 1;
    GC1_FormString = StringCnC1;
		if(( DEF_SYSTEMFORM== LastForm) && (HREG_CONTROLLER_TYPE_SET == ModifyCur))
		{
    ControllerSet1 = (GetJDParamValue(ModifyCur)&0x00FF);
	  ControllerSet2 = (GetJDParamValue(ModifyCur)>>8)&0x00FF;
		GC_FormString = StringCnC;
		GC1_FormString = StringCnC1;
    GC2_FormString = StringCnC2;
    GC3_FormString = StringCnC3;
    GC4_FormString = StringCnC4;
    GC5_FormString = StringCnC5;
    GC6_FormString = StringCnC6;
    GC7_FormString = StringCnC7;
    GC8_FormString = StringCnC8;
    GC9_FormString = StringCnC9;
    GC10_FormString = StringCnC10;
    GC11_FormString = StringCnC11;
    GC12_FormString = StringCnC12;
    GC13_FormString = StringCnC13;
    GC14_FormString = StringCnC14;
    GC15_FormString = StringCnC15;
    GC16_FormString = StringCnC16;
    GC17_FormString = StringCnC17;		
    GC18_FormString = StringCnC18;
    GC19_FormString = StringCnC19;
		}
    DispParam();
    auto_return = 0;
    return;
  }

  if (FormStatus == STATUS_QUIT)
  {
    ActiveForm = FormTo;
    FormStatus = STATUS_INIT;
    return;
  }

   OneSecTick();

  e = GetEvent();
  if (e)
  {
    switch (e->eType)
    {
    case keyUpEvent:
      ParamModifyFormProcReleaseKey(e->DATA.keyDown.chr);
      break;
    case keyRepeatEvent:
      ParamModifyFormProcRepeatKey(e->DATA.keyDown.chr);
      break;
    case rmtUpdateEvent:

      if (++auto_return > 600) //�����÷�ʽ�������30����û�а����������򷵻������档
      {
				
        Return(DEF_MAINFORM);
      }
      break;
    default:
      break;
    }
  }
}

void DisPlayOneDotTemp(s16 ValueToEdit)
{
  s16 ret1, ret2, ret3, ret;

  if ((ValueToEdit > 1000) && (ValueToEdit < 10000))
  {
    ret = ValueToEdit % 10;
    if (ret < 5)
    {
      ValueToEdit = (ValueToEdit - ret) / 10;
    }
    else
    {
      ValueToEdit = (ValueToEdit - ret) / 10 + 1;
    }
    DisplayMainValues(ValueToEdit, 0, 0);
  }
  else if ((ValueToEdit <= -100) && (ValueToEdit >= -1000))
  {
    ret1 = ValueToEdit / 100;
    ret2 = (ValueToEdit - 100 * ret1) / 10;
    ret3 = ValueToEdit - 100 * ret1 - ret2 * 10;
    if (ret3 < -5)
    {
      ValueToEdit = (ValueToEdit - ret3) / 10 - 1;
    }
    else
    {
      ValueToEdit = (ValueToEdit - ret3) / 10;
    }
    DisplayMainValues(ValueToEdit, 0, 0);
  }
  else
  {
    DisplayMainValues(ValueToEdit, 0, ONE_DOT);
  }
}
